<template>
  <hsProjectTemplate ref="listRef" isRemote currentPageType="twoCalculationsAndOneControlBaseData"
    :downProjectInterface="queryProjectBuildAreaListApi" :queryInterface="queryProjectBuildAreaListApi" pageAttr="pageNo"
    :setTableCloumns="setCloumn" projectValueAttr="projectCode" projectNameAttr="projectName">
    <template #queryOperateBtn>
      <el-button class="zs-btn-primary" @click="handleDownload">
        <el-icon class="el-icon--left">
          <Upload /> 
        </el-icon>导出
      </el-button>
    </template>
  </hsProjectTemplate>
</template>

<script setup>
// import ProjectTemplate from './projectTemplate.vue'
import { toThousands } from '@/utils/number-util'
import { downloadNewFile } from "@/utils/publicUtils"
import {
  queryProjectBuildAreaListApi,
  exportProjectBuildAreaListApi
} from "@/api/SpecialReport/index";

import { useStore } from "vuex";
const store = useStore()
const dictObj = store.getters.getDictObj(['PROJECT_COMMERCIAL_ACTIVITIES'])
let curbizType = {}
dictObj.PROJECT_COMMERCIAL_ACTIVITIES.forEach((el)=>{
  curbizType[el.dictValue] = el.dictLabel
})

function setCloumn (cloumn) {
  let currentCloumns = [
    { prop: 'totalAreaGarage', label: '总建筑面积(含车库)', align: 'right', type: 'customMethods', methods: (row,empty) => row.totalAreaGarage ? toThousands(row.totalAreaGarage) : empty },
    { prop: 'businessArea', label: '商业面积(不含车库)', align: 'right', type: 'customMethods', methods: (row,empty) => row.businessArea ? toThousands(row.businessArea) : empty  },
    { prop: 'instruction', label: '说明', align: 'left'},
  ]
  return cloumn.concat(currentCloumns)
}


function handleDownload() {
  exportProjectBuildAreaListApi({}).then(res=>{
    downloadNewFile(res.data, `项目建筑面积明细.xls`)
  })
  
}
</script>

<style lang="scss" scoped></style>